<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsppages/include/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title><%=system_name%> - 部门管理</title>
	<base href="<%=basePath%>" />
	<link type="image/x-icon" rel="shortcut icon" href="<%=basePath%>images/favicon.ico" />
 	<meta http-equiv="pragma" content="no-cache" />
 	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />
	<link href="css/style.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/common.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/userlist.css" rel="stylesheet" type="text/css" />
	<script src="<%=basePath%>js/common.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/pagebar_cn.js"></script>
	<script type="text/javascript" src="fram/engine.js" ></script>
	<script type="text/javascript" src="fram/util.js" ></script>
	<script type="text/javascript" src="fram/interface/userService.js"></script>
</head>

<body oncontextmenu='return false'>

	<!--top begin-->
	<%@include file="/WEB-INF/jsppages/admin/head.jsp"%>
	<!--top end-->


<div class="wrap100 content">

    <!--left begin-->
	<%@include file="/WEB-INF/jsppages/admin/left.jsp"%>
    <!--left end-->
    
    
    <!--right begin-->
<div class="right">
            <div class="search">
                <form action="<%=basePath%>trade/deptList" method="GET">
                <table width="100%" border="0" cellspacing="0" cellpadding="5">
                  <tr>
                    <td width="5%"><img src="images/marking1.gif" width="41" height="44" alt="marking" /></td>
                    <td width="8%">快速查询</td>
                    <td width="45%">请输入部门名称：<input type="text" name="deptName" value="${deptSearchCond.deptName}" style="width:200px;" /></td></td>
                    <td width="11%">
                    <input type="submit" style="background:url(images/searchBtn.gif);width:116px;height:30px;border:0;margin:0;" value="" />
                    </td>
                    <td width="30%">
                    <jsp:useBean id="nowDate" class="java.util.Date"></jsp:useBean>
   					 现在是：${formatDate}<fmt:formatDate value="${nowDate}" type="both" dateStyle="full"/>
   					</td>
                    <td width="1%">&nbsp;</td>
                  </tr>
                </table>    
                </form>
    
        </div>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="60"><h1>部门管理</h1></td>
              </tr>
            </table>
           
            <div class="rightContentTop">
              <div class="subMenu">
                <ul>
                  <li><a href="#" class="current">部门列表</a></li>
                </ul>
              </div>
    </div>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="right"><span style="float:left;color:#666;">共找到<font color="red"> ${searchStat.totalCount} </font>条记录</span><a href="javascript:;" onclick="addDept()" style="font-weight:bold"><img src="images/add.gif" width="90" height="31" alt="添加部门" /></a><!-- <a href="#"><img src="images/del.gif" width="90" height="31" alt="删除" /></a>--></td>
              </tr>
            </table>
            <div class="rightContent1">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr class="td">
                  <th width="4%" align="center" bgcolor="#f9f9f9"><input type="checkbox" name="checkbox4" id="checkbox4" /></th>
                  <th width="40%" align="center" bgcolor="#f9f9f9">部门编号</th>
                  <th width="16%" align="center" bgcolor="#f9f9f9">部门名称</th>
                  <th width="33%" align="center" bgcolor="#f9f9f9">备注</th>
                  <th width="7%" align="center" bgcolor="#f9f9f9">操作</th>
                </tr>
                <c:forEach var="dept" items="${deptList}">
                <tr>
                  <td align="center"><input type="checkbox" name="checkbox" id="checkbox" value="${dept.id}"/></td>
                  <td align="center">${dept.id}</td>
                  <td align="center">${dept.deptName}</td>
                  <td>${dept.remark}</td>
                  <td align="left"><a href="javascript:;" onclick="delDept('${dept.id}')"><img src="images/del1.jpg" alt="删除" /></a> <a href="javascript:;" onclick="editDept('${dept.id}')"><img src="images/modify.jpg" alt="修改" /></a></td>
                </tr>
                </c:forEach>
                <c:if test="${empty deptList}"><tr><td colspan="5" style="text-align:center">没有相关记录！</td></tr></c:if>
              </table>
            </div>
            <!-- 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><a href="zmateAdd.htm"><br />
                </a>　<a href="#"><img src="images/del.gif" width="90" height="31" alt="删除" /></a></td>
              </tr>
            </table> -->
           <script type="text/javascript">
		var pageControl = new wpagebar('pageControl');
		pageControl.argName = "pageIndex";
		pageControl.pageCount =${searchStat.pageCount};
		pageControl.load();		
  	</script>
          
    <div id="win_temp" style="display:none">
  	<div id="winCon_1"  >
	<table class="tabView" style="margin-top:5px">
		<tr><th width="100">部门名称：</th><td><input type="text" name="deptName0" id="deptName0" value=""/><input type="text" name="dpId0" id="dpId0" value="" style="display:none"/></td></tr>
		<tr><th>备注：</th><td><textarea name="remark0" id="remark0" rows="3" cols="25"></textarea> </td></tr>
		<tr><td colspan="2" style="text-align:center;height:"><input type="button" value=" 提 交 " class="btn1" onclick="submitDept()"/></td></tr>
	</table>
	</div>
  </div>
  <script src="<%=basePath%>js/win.js" type="text/javascript"></script>

<script  type="text/javascript">
function addDept(){
	WIN.show('添加部门',$('winCon_1'),{height:190});
}
function editDept(id){
	WIN.show('修改部门',$('winCon_1'),{height:190});
	userService.getDeptById(id,function(data){
		$('dpId0').value=data.id;
		$('deptName0').value=data.deptName;
		$('remark0').value=data.remark;
	})
}
function delDept(id){
	if(confirm("删除部门，将删除部门下的人员,确定删除 ？")){
		WIN.showpg();
		userService.delDept(id,{
			callback:function(f){WIN.closepg();alert("删除成功");reload();},
			exceptionHandler:function(message){WIN.closepg();alert(message);alert("删除失败，请重试");},
			errorHander:function(err){}
		})
	}
}

function submitDept(){
	var dept={
		id:		$('dpId0').value,
		deptName:	$('deptName0').value,
		remark:	$('remark0').value
	}
	WIN.close();
	WIN.showpg();
	userService.editDept(dept,{
		callback:function(f){WIN.closepg();alert("操作成功");reload();},
		exceptionHandler:function(message){WIN.closepg();alert(message);alert("操作失败，请重试");},
		errorHander:function(err){}
	})
}

</script>
</body>
</html>
